
"""
抽取章节的人物简介信息
"""
from models import Chapter
from pydantic import Field
from core.utils import BaseAnalyzer, prompt_dir


class SimplyExtractor(BaseAnalyzer):

    def __init__(self):
        super().__init__(prompt_file= prompt_dir / 'alone/a1. 人物简介抽取.md')

    def invoke(
            self,
            chapter: Chapter = Field(description="章节信息")
    ):
        prompt = self.template_prompt.format(
            inputs={
                "chapter_content": chapter.chapter_content
            },
            remove_template_variables=True
        )
        chapter.character_profile = self.analyze(prompt)
        return chapter.character_profile
